home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / exbine.zip / SIMPLE.PAS < prev   
Pascal/Delphi Source File  |  1993-01-04  |  1KB  |  28 lines

  1. program Simple;  {SIMPLE.PAS: A simple editor using the BINED unit}
  2.  
  3. uses BinEd, Crt;
  4.  
  5. const ExitCommands : Char = #0;   {No extra exit commands}
  6. var EdData : EdCB;              {Editor control block}
  7.  
  8.   procedure Abort(Msg : String);
  9.   begin  {Abort}
  10.     GotoXY(1, 25); Write(Msg); Halt(1);
  11.   end;   {Abort}
  12.  
  13. begin  {main}
  14.   if (ParamCount = 0) then                      {No filename}
  15.      Abort('Usage: SIMPLE filename.ext');
  16.   if (InitBinaryEditor(EdData, MaxFileSize, 1, 1, 80, 25,
  17.      True, EdOptInsert, '', ExitCommands, nil) <> 0) then
  18.        Abort('Unable to load binary editor.');  {Couldn't load editor}
  19.   if (ReadFileBinaryEditor(EdData, ParamStr(1)) > 1) then
  20.      Abort('Unable to read ' + ParamStr(1));    {Couldn't read file}
  21.   ResetBinaryEditor(EdData);                    {Reset for new file}
  22.   if (UseBinaryEditor(EdData, '') = -1) then    {Edit the file}
  23.      if ModifiedFileBinaryEditor(EdData) then   {Was it modified?}
  24.         if (SaveFileBinaryEditor(EdData, True) <> 0) then {Save it}
  25.            Abort('Error saving file.');
  26.   GotoXY(1,25);
  27. end.   {main}
  28.